package cn.neusoft.controller;

import cn.neusoft.domain.Statistics;
import cn.neusoft.query.BaseQuery;
import cn.neusoft.query.StatisticsQuery;
import cn.neusoft.service.StatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/statistic")
@Api(value = "数据模块的API",description="数据模块")
public class StatisticController {

    @Autowired
    private StatisticsService statisticsService;

    @PostMapping("/topSoldCommodity")
    @ApiOperation(value = "查询一个时间段内的销量" )
    public List<Statistics> getTopFiveCommodityInTimeRange(StatisticsQuery statisticsQuery){
        return statisticsService.getTopFiveCommodityInTimeRange(statisticsQuery);
    }

    @PostMapping("/topReturnCommodity")
    @ApiOperation(value = "查询一个时间段内的退货量" )
    public List<Statistics> getCommodityOrderReturnQuantityInTimeRange(StatisticsQuery statisticsQuery){
        return statisticsService.getCommodityOrderReturnQuantityInTimeRange(statisticsQuery);
    }

    @GetMapping("/getTotalByDay")
    @ApiOperation(value = "查询出当天的订单量" )
    public List<Statistics> getTotalOrderByDay(){
        return statisticsService.getTotalOrderByDay();
    }

    @GetMapping("/getTotalByMonth")
    @ApiOperation(value = "查询出当月的进货量" )
    public List<Statistics> getTotalOrderByMonth(){
        return statisticsService.getTotalOrderByMonth();
    }

    @GetMapping("/getOpByDay")
    @ApiOperation(value = "查询所有操作员当日操作量" )
    public List<Statistics> getOpByDay(){
        return statisticsService.getOpByDay();
    }

    @GetMapping("/getOpByMonth")
    @ApiOperation(value = "查询所有操作员当月操作量" )
    public List<Statistics> getOpByMonth(){
        return statisticsService.getOpByMonth();
    }

    @GetMapping("/getOpByAll")
    @ApiOperation(value = "查询所有操作员所有操作量" )
    public List<Statistics> getOpByAll(){
        return statisticsService.getOpByAll();
    }

    @GetMapping("/getStorage")
    @ApiOperation(value = "查询中心库房库存" )
    public List<Statistics> getStorage(){
        return statisticsService.getStorage();
    }

    @GetMapping("/getOrderByProvince")
    @ApiOperation(value = "查询行政区订单数" )
    public List<Map<String, Object>> getOrderByProvince(){
        return statisticsService.getOrderByProvince();
    }

    @GetMapping("/getNormalOrderByMonth")
    @ApiOperation(value = "查询当月正常订单" )
    public String[] getNormalOrderByMonth(){
        return statisticsService.getNormalOrderByMonth();
    }

    @GetMapping("/getExchangeOrderByMonth")
    @ApiOperation(value = "查询当月换货订单" )
    public String[] getExchangeOrderByMonth(){
        return statisticsService.getExchangeOrderByMonth();
    }

    @GetMapping("/getReturnOrderByMonth")
    @ApiOperation(value = "查询当月退货订单" )
    public String[] getReturnOrderByMonth(){
        return statisticsService.getReturnOrderByMonth();
    }
}
